import React, { useReducer } from "react";
import { defaultState, reducer } from "./store/reducer";

const App = () => {
  // useReducer里面要传入两个参数，分别reducer和defaultState
  // 返回值是一个数组
  const [state, dispatch] = useReducer(reducer, defaultState);
  return (
    <>
      <h2>useReducer</h2>
      <span>{state.count}</span>
      <button onClick={() => dispatch({ type: "add" })}>+</button>
    </>
  );
};

export default App;
